package com.nondo.dean.dealer.controller.api.app;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.nondo.dean.common.annotation.ApiVersion;
import com.nondo.dean.common.web.View;
import com.nondo.dean.dealer.domain.Store;
import com.nondo.dean.dealer.service.StoreService;

/**
 * @author ken.
 * @version 1.0
 * @email 695093513@qq.com
 * @date 2018/3/28
 */
@RestController("apiAppDealerStore")
@RequestMapping("/{v}/app/store")
public class StoreController {
    @Autowired
    StoreService storeService;
    
    /**
     * 获取店铺首页信息
     *
     * @param request
     * @param response
     * @return
     */
    @ApiVersion(1)
    @RequestMapping("/index")
    public View<Store> index(HttpServletRequest request, HttpServletResponse response) {
        View<Store> view = new View<Store>(20000, "获取数据成功");

        Store store = this.storeService.index();

        view.setData(store);

        return view;
    }
    
    /**
     * 修改店铺信息
     *
     * @param request
     * @param response
     * @param store
     * @return
     */
    @ApiVersion(1)
    @RequestMapping("/update")
    public View<Store> update(HttpServletRequest request, HttpServletResponse response, @RequestBody Store store) {
        View<Store> view = new View<Store>(20000, "更新店铺信息成功");

        store = this.storeService.appUpdate(store);

        view.setData(store);

        return view;
    }
}
